#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int find(int p[],int sz,int k) {
	int left = 0;
	int right = sz - 1;
	while (left<=right) {
		int mid = left + (right - left) / 2;
		if (k > p[mid]) {
			left = mid + 1;
		}
		else if (k < p[mid]) {
			right = mid - 1;
		}
		else return mid;
	}
}

int main() {
	int arr[] = { 1,2,3,4,5 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	int k = 2;
	int n=find(arr,sz,k);
	printf("%d", n);
}